package com.ej.demo.page;

import static org.testng.AssertJUnit.assertEquals;

import com.thoughtworks.selenium.Selenium;

public class CheckoutPage {

	private Selenium selenium;
	String continueButton = "//a[@id='continueButton']/span";
	
	public CheckoutPage() {
		selenium = eJTestBase.getSeleniumObj();
	}

	public CheckoutPage selectNewUserOption() {
		selenium.click("rbNewUser");
		selenium.click(continueButton);
		String checkoutPageNewUserFormHeader = "//div[@id='memberDetail']/div[2]/div[2]/div/div/h2";
		for (int second = 0;; second++) {
			if (second >= 60)
				break;
			try {
				
				if (selenium
						.isElementPresent(checkoutPageNewUserFormHeader))
					break;
			} catch (Exception e) {
			}
			try {
				Thread.sleep(1000);
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		return this;
	}

	public CheckoutPage verifyContactDetailsForm() {
		// TODO Auto-generated method stub
		assertEquals(selenium.getText("Step5HeaderFillIn"),
				"Fill in your passenger details and pay");
		assertEquals(selenium
				.getText("//div[@id='memberDetail']/div[2]/div[2]/div/div/h2"),
				"Your contact details");
		return this;
	}

	public void verifyPassengerDetailsForm() {
		// TODO Auto-generated method stub

		assertEquals(
				selenium
						.getText("//div[@id='addEditPassengerDetailsPanel']/div/div[2]/div/div/h2"),
				"Passenger Details");
	}

}
